package com.example.hello.pojo;

import lombok.Data;

/**
 * 后端统一返回结果
 */
@Data
public class Res {

    private Integer code; //编码：1成功，0为失败
    private String msg; //错误信息
    private Object data; //数据

    public static Res success() {
        Res res = new Res();
        res.code = 1;
        res.msg = "success";
        return res;
    }

    public static Res success(Object object) {
        Res res = new Res();
        res.data = object;
        res.code = 1;
        res.msg = "success";
        return res;
    }

    public static Res error(String msg) {
        Res res = new Res();
        res.msg = msg;
        res.code = 0;
        return res;
    }

}